import com.example.spring5.model.User;
import com.example.spring5.service.impl.UserServiceImpl;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;



public class UserText {
    ClassPathXmlApplicationContext application;

    @Before
    public void before() {
        application = new ClassPathXmlApplicationContext("applicationContext.xml");
    }

    @Test
    public void insertUser() {
        UserServiceImpl bean = application.getBean(UserServiceImpl.class);
        bean.insertUser(new User(2, "王五", "1256", "小王", "2"));
    }

    @Test
    public void selectByUser() {
        UserServiceImpl bean = application.getBean(UserServiceImpl.class);
        System.out.println(bean.selectById(2));
    }

    @Test
    public void updateNameById() {
        UserServiceImpl bean = application.getBean(UserServiceImpl.class);
        bean.updateNameById(new User(2, "赵六", "1298", "小六", "2"));
    }

    @Test
    public void delete() {
        UserServiceImpl bean = application.getBean(UserServiceImpl.class);
        bean.delete(2);


    }
}
